package com.lc.hongtai.conn;

import android.util.Log;

import com.google.gson.Gson;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

import java.util.List;

/**
 * Created by Administrator on 4/19/2016.
 */
@HttpInlet("index/index")
public class JsonIndex extends HYAsyPost<JsonIndex.Info> {
    public String access_token;

    public JsonIndex(String access_token, AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
        this.access_token = access_token;
    }

    @Override
    protected Info parser(JSONObject object) {
/*
        Info info = null;
        if (object.optString("status").equals("1")) {
            info = new Info();
            info.news_id = object.optString("news_id");
            JSONArray array = object.optJSONArray("banner");
            List<Info.BannerListContent> bannerList = new ArrayList();
            for (int i = 0; i < array.length(); i++) {
                JSONObject object1 = array.optJSONObject(i);
                Info.BannerListContent listContent = new Info.BannerListContent();
                listContent.img = object1.optString("img");
                listContent.url = object1.optString("url");
                listContent.title = object1.optString("title");
                bannerList.add(listContent);
            }
            info.banner = bannerList;
            JSONArray array1 = object.optJSONArray("menuList");
            List<Info.MenuListContent> menuList = new ArrayList();
            for (int i = 0; i < array1.length(); i++) {
                JSONObject object1 = array1.optJSONObject(i);
                Info.MenuListContent listContent = new Info.MenuListContent();
                listContent.title = object1.optString("title");
                listContent.desc = object1.optString("desc");
                menuList.add(listContent);
            }
            info.menuList = menuList;
            TOAST = object.optString("tips");
            return info;
        }

        TOAST = object.optString("tips");

        return null;*/

        Log.d(object.toString(),"asdf");

        Info info = new Info();
        Gson gson = new Gson();
        info = gson.fromJson(object.toString(), Info.class);

        return info;


    }

    public static class Info {
        public String news_id;
        public List<BannerListContent> banner;

        public List<Borrow_list> menu;
        public List<BannerMiddle> banner_middle;

        public List<notice> news;

        public List<New_menu> xs_menu;



        public static class Linek_img{
            public String link_img;
        }





        public static class notice{
            public String id;
            public String title;

        }


        public static class BannerListContent {
            public String img;
                 public String url;
            public String title;
        }


        public static class Borrow_list {
            public String id;
            public String borrow_name;
            public String borrow_interest_rate;
            public String borrow_duration;
            public String borrow_duration_cn;

            public String borrow_min;

            public String borrow_money;


            public String need;
            public String progress;
        }



        public static class BannerMiddle{
            public String img;

            public String title;
            public String url;

        }





        public static class New_menu {
            public String id;
            public String borrow_min;
            public String borrow_times;
            public String borrow_duration;
            public String borrow_interest_rate;

            public String progress;

            public String borrow_duration_cn;



        }



    }
}
